#include <STC15F2K60S2.H>
#include <INTRINS.H>
extern uint csb_jz_340 ;
extern char xiaozhun;
sbit TX = P1^0;
sbit RX = P1^1;

void Delay13us()		//@12.000MHz
{
	unsigned char i;

	_nop_();
	_nop_();
	i = 38;
	while (--i);
}


void CSB_int()
{
	uchar i;
	for(i=0;i<8;i++)
	{
		TX = 1;
		Delay13us()	;
		TX = 0;
		Delay13us()	;
	}
}



uint csb_read()
{
	uint CSB =0;
	CMOD = 0;
	CL = CH = 0;
	EA = 0;
	CSB_int();
	EA = 1;
	
	CR = 1;
	while((RX == 1 )&& (CF == 0));
	CR = 0;
	if(CF == 0)
	{
		CSB = (CH<<8) |CL;
		
		return (CSB*((csb_jz_340/2.0)/10000.0)+xiaozhun);
	}else{
			CF = 0;
			return 0;
		 }




}